package com.fas.system.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.logging.log4j.util.Strings;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 小程序巡检员下的线路
 */
public class IpqcInspectionLine implements Serializable {

    @JsonSerialize(using = LongJsonSerializer.class)
    @JsonDeserialize(using = LongJsonDeserializer.class)
    private Long id;// 巡检任务id
    @JsonSerialize(using = LongJsonSerializer.class)
    @JsonDeserialize(using = LongJsonDeserializer.class)
    private Long lineId;//路线id
//    private Integer status;// 巡检路线状态（0：已完成，1：进行中，2：待开始）
    private Integer orderType;//工单类型（0：巡检工单，2：设备报警、故障工单）
    private Integer lineStatus;//巡检路线状态（ 0：已完成，1：进行中）
    private Integer treatmentMethod;//处理方式（0：现场处理，1：上报工单）

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @JsonIgnore
    private String userStr;// 用户列表
    @JsonIgnore
    private List<Integer> userList;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getLineId() {
        return lineId;
    }

    public void setLineId(Long lineId) {
        this.lineId = lineId;
    }

    public String getUserStr() {
        return userStr;
    }

    public void setUserStr(String userStr) {
        if (Strings.isNotBlank(userStr)) {
            String[] split = userStr.split(",");
            this.userList = Stream.of(split).map(Integer::parseInt).collect(Collectors.toList());
        }
        this.userStr = userStr;
    }

    public List<Integer> getUserList() {
        return userList;
    }

    public void setUserList(List<Integer> userList) {
        if (!Objects.isNull(userList)) {
            this.userStr = userList.stream().map(String::valueOf).collect(Collectors.joining(","));
        }
    }

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public Integer getLineStatus() {
        return lineStatus;
    }

    public void setLineStatus(Integer lineStatus) {
        this.lineStatus = lineStatus;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
